﻿using Core.Combat.Data;
using Sirenix.OdinInspector;
using UnityEngine;

namespace Core.Combat.FlyerObj.Data
{
    [CreateAssetMenu(menuName = "DataModel/子弹配置数据")]
    public class BulletDataModel : ScriptableObject
    {
        public BulletData bulletData;
    }

    [System.Serializable]
    public class BulletData
    {
        public float bulletLiveTime = 10f;
        public float flyingSpeed;
        
        [Title("发射核心的属性")]
        public BulletFireCoreData fireCoreData;
        [Title("行为核心的属性")]
        public BulletBehaviourCoreData behaviourCoreData;
        [Title("效果核心的属性")]
        public BulletEffectCoreData effectCoreData;

        public void InitData(BulletDataModel dataModel)
        {
            InitData(dataModel.bulletData);
        }

        public void InitData(BulletData data)
        {
            fireCoreData ??= new BulletFireCoreData();
            behaviourCoreData ??= new BulletBehaviourCoreData();
            effectCoreData ??= new BulletEffectCoreData();

            flyingSpeed = data.flyingSpeed;
            var f_coreData = data.fireCoreData;
            var b_coreData = data.behaviourCoreData;
            var e_coreData = data.effectCoreData;
            fireCoreData.fireRate = f_coreData.fireRate;
            fireCoreData.fireTotalNum = f_coreData.fireTotalNum;
            fireCoreData.fireDriftAngle = f_coreData.fireDriftAngle;
            fireCoreData.scatterAngle = f_coreData.scatterAngle;
            fireCoreData.scatterType = f_coreData.scatterType;

            behaviourCoreData.penetrateNumber = b_coreData.penetrateNumber;
            // behaviourCoreData.reboundAsthenia = b_coreData.reboundAsthenia;
            behaviourCoreData.reboundsNumber = b_coreData.reboundsNumber;
            behaviourCoreData.splitNumber = b_coreData.splitNumber;
            behaviourCoreData.traceIntensity = b_coreData.traceIntensity;
            behaviourCoreData.traceRange = b_coreData.traceRange;
            // behaviourCoreData.traceResponsiveTime = b_coreData.traceResponsiveTime;
            
        }
    }
}